﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DalatCooking.Core;
using DalatCooking.Core.Helper;
public partial class admin_Course_Orders : System.Web.UI.Page
{
    public int total = 0;
    protected void Page_Load(object sender, EventArgs e)
    {

        // Response.Write(IsPublished.ToString());

    }
    protected override void OnInit(EventArgs e)
    {
        BinData();

        base.OnInit(e);
    }

    public int ProductID
    {
        get
        {
            if (Request.QueryString["ProductID"] != null)
                return ConvertObject.ToInt(Server.HtmlEncode(Request.QueryString["ProductID"]));
            else return -1;
        }
    }
    bool IsPublished
    {
        get { return ConvertObject.ToBool(Request.QueryString["IsPublished"] != null); }
    }

    public bool Published
    {
        get
        {
            if (Request.QueryString["IsPublished"] != null)
                return ConvertObject.ToBool(Request.QueryString["IsPublished"]);

            return false;
        }
    }
    void BinData()
    {
        int pageSize = 10;
        if (Request.Cookies["postPageSize"] != null)
        {
            pageSize = ConvertObject.ToInt(Server.HtmlEncode(Request.Cookies["postPageSize"].Value));
        }
        else
        {
            pageSize = 10;// Settings.SettingInt("site.pagesize");
        }

        int pageNum = 1;

        if (Request.QueryString[PagingControl1.QueryStringKey] != null)
        {
            pageNum = ConvertObject.ToInt(Server.HtmlEncode(Request.QueryString[PagingControl1.QueryStringKey]));
        }
        else pageNum = 1;

        //Repeater1.DataSource =  BusinessLayer.Entities.Menu.All();



       rpt.DataSource = OrdersManager.PagingSql(pageSize, pageNum, out total);
        //rpt.DataSource = Contents.All();
        rpt.DataBind();

        PagingControl1.TotalPage = total;
        PagingControl1.CurrentPage = pageNum;
        PagingControl1.PageSize = pageSize;


        PagingControl2.TotalPage = total;
        PagingControl2.CurrentPage = pageNum;
        PagingControl2.PageSize = pageSize;

    }
    public string GetPerson(object pId)
    {
        Person p = PersonManager.FindById(ConvertObject.ToInt(pId));
        return (p != null) ? p.UserName : "";
    }
    public int Count()
    {
        return total;
    }
   
}